home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / gnu / gawk / gawk213b.zoo / test / sortdir1.awk < prev    next >
Text File  |  1991-04-06  |  395b  |  20 lines

  1. #
  2. # A demo of using your own temporary files with gawk
  3. # Use as in 'gawk -f sortdir1.awk > outs'
  4. #
  5. # !!! WILL CREATE (OR OVERWRITE) FILE ls.tmp  -- WATCH OUT !!!
  6. #
  7. BEGIN {
  8.     cmd1 = "ls -l"
  9.     cmd2 = "sort -n +3"
  10.     tmpfile = "ls.tmp"
  11.     while ((cmd1 | getline) > 0)
  12.         print $0 > tmpfile
  13.     close (cmd1)
  14.     close (tmpfile)
  15.     while ((getline < tmpfile) > 0)
  16.         print $0 | cmd2
  17.     close (cmd2)
  18.     close (tmpfile)
  19. }
  20.